#!/usr/bin/env python
# -*- coding: UTF-8 -*-
"""
@Project: Jmpy
@File   : jmp_dataframe.py
@Author : Link
@Date   : 2025/4/29 18:39
@Remark :

"""
from string import Template


class JmpyColType:
    Float = "Continuous"  # 数值型
    String = "Nominal"  # 名义型
    Bin = "Ordinal"  # 有序型
    Expression = "Expression"  # 表达式, 类似图形


class JmpDataFrame:
    """
    JMP的数据帧处理接口
    """

    @staticmethod
    def jSetColType(col: str, typ: str, dt: str = "dt"):
        """

        :param dt:
        :param col:
        :param typ:
        :return:
        """
        return Template(
            """
$dt :$col << Set Modeling Type($typ);
            """
        ).substitute(**locals())

    @staticmethod
    def jAddSpecification(col: str, lsl: float, usl: float, dt: str = "dt") -> str:
        """

        :param dt:
        :param col:
        :param lsl:
        :param usl:
        :return:
        """
        return Template(
            """
$dt :"$col"n << Set Property( "Spec Limits", {LSL( $lsl ), USL( $usl ), Show Limits( 1 )} );
            """
        ).substitute(**locals())

    @staticmethod
    def jNewScript(name, script, dt: str = "dt") -> str:
        """
        记得调用Script的时候, 需要显示的调用TableLoad
        """
        return Template(
            """
$dt << New Script( "$name", $script );
            """
        ).substitute(**locals())
